from django.contrib import admin
from django.urls import path, include
from django.http import JsonResponse
from django.views.decorators.cache import never_cache
from django.views.generic import RedirectView
from django.conf import settings
from django.conf.urls.static import static
from django.utils import timezone

@never_cache
def health_check(request):
    """健康检查端点"""
    return JsonResponse({
        'status': 'healthy',
        'timestamp': timezone.now().isoformat()
    })

urlpatterns = [
    path('admin/', admin.site.urls),
    path('health/', health_check, name='health_check'),
    path('admin', RedirectView.as_view(url='/admin/')),
    # path('', RedirectView.as_view(url='/admin')),
    path('v1/users/', include('users.urls')),
    path('v1/shipping/', include('shipping.urls')),
    path('v1/opration/', include('opration.urls')),
]

# 在开发环境中添加静态文件和媒体文件的URL
if settings.DEBUG:
    urlpatterns += static('/django-static/', document_root=settings.STATIC_ROOT)
    urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
